Skip to content

Add trusted cloud configuration - #20294

Open
Tate Smalligan (tsmallig33) wants to merge 5 commits into
mainfrom
tasmalligan/AddTrustedCloudConfiguration
Open

Add trusted cloud configuration#20294
Tate Smalligan (tsmallig33) wants to merge 5 commits into
mainfrom
tasmalligan/AddTrustedCloudConfiguration

Conversation

@tsmallig33

@tsmallig33 Tate Smalligan (tsmallig33) commented Sep 9, 2026

Copy link
Copy Markdown
Member

Description

Add Trusted Cloud Configuration. Custom Clouds will require setting env variable BICEP_TRUSTED_CLOUDS similar to the Trusted Registries Implementation.

Example Usage

Note: Custom Clouds which are not included in the built in list will need to set the trusted clouds environment variable

$env:BICEP_TRUSTED_CLOUDS = '[{"resourceManagerEndpoint":"https://management.example.com","activeDirectoryAuthority":"https://login.example.com"}]'

Checklist

Microsoft Reviewers: Open in CodeFlow

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Test this change out locally with the following install scripts (Action run 34499190358)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 34499190358
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 34499190358"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 34499190358
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 34499190358"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

ACR completion ARM client construction currently ignores the configured cloud environment options, which can break non-public-cloud endpoint behavior.

Pull request overview

Adds a “trusted cloud” gate to prevent credentials/tokens and registry/ARM traffic from being directed through attacker-controlled custom cloud profiles unless explicitly approved via BICEP_TRUSTED_CLOUDS. This fits into Bicep’s security model alongside trusted registries by ensuring the cloud profile itself is trusted before any networked Azure/registry operations occur.

Changes:

  • Introduces CloudConfigurationTrustPolicy (built-ins trusted; custom/modified require BICEP_TRUSTED_CLOUDS) and wires it into DI.
  • Blocks OCI/module restore/publish, Template Spec restore, ARM client creation, and completion-time registry discovery when the active cloud is untrusted (new diagnostics BCP456/BCP457).
  • Updates built-in cloud profiles (Bleu/Germany) and VS Code bicepconfig schema, with new/updated unit tests.
File summaries
File Description
src/vscode-bicep/resources/configuration/bicepconfig.schema.json Document trust model + new built-ins
src/Bicep.Wasm/WasmModuleRegistryProvider.cs Pass trust policy into OCI registry
src/Bicep.LangServer/Features/Language/Completion/ModuleReferenceCompletionProvider.cs Skip unsafe registry completions
src/Bicep.LangServer/Features/Language/Completion/AzureContainerRegistriesProvider.cs Enforce trusted cloud before ARM queries
src/Bicep.LangServer/Features/Custom/InsertResource/AzResourceProvider.cs Enforce trusted cloud before ARM client
src/Bicep.LangServer.UnitTests/Handlers/BicepExternalSourceDocumentLinkHandlerTests.cs Update config manager construction
src/Bicep.LangServer.UnitTests/Configuration/BicepConfigChangeHandlerTests.cs Update config manager construction
src/Bicep.LangServer.UnitTests/Completions/ModuleReferenceCompletionProviderTests.cs Add/adjust untrusted-cloud completion tests
src/Bicep.Core/Registry/TemplateSpecModuleRegistry.cs Block Template Spec restore on untrusted cloud
src/Bicep.Core/Registry/OciArtifactRegistry.cs Block OCI operations on untrusted cloud
src/Bicep.Core/Registry/DefaultArtifactRegistryProvider.cs Plumb trust policy into registries
src/Bicep.Core/Registry/ContainerRegistryClientFactory.cs Enforce trusted cloud before ACR clients
src/Bicep.Core/Registry/Catalog/Implementation/RegistryModuleCatalog.cs Enforce trusted cloud before catalog providers
src/Bicep.Core/Diagnostics/DiagnosticBuilder.cs Add BCP456/BCP457 diagnostics
src/Bicep.Core/Configuration/CloudConfigurationTrustPolicy.cs New: trust policy + env parsing/normalization
src/Bicep.Core/Configuration/BicepConfigurationManager.cs Add trust diagnostics at config bind time
src/Bicep.Core/Configuration/bicepconfig.json Add built-in Bleu/Germany profiles
src/Bicep.Core/BicepCoreServiceCollectionExtensions.cs Register trust policy from environment
src/Bicep.Core/AzureApi/TokenCredentialFactory.cs Gate credential acquisition by trusted authority
src/Bicep.Core/AzureApi/ArmClientProvider.cs Gate ARM client creation by trusted cloud
src/Bicep.Core.UnitTests/Utils/RegistryHelper.cs Update config manager construction
src/Bicep.Core.UnitTests/Utils/OciRegistryHelper.cs Pass trust policy into OCI registry
src/Bicep.Core.UnitTests/Registry/TokenCredentialFactoryTests.cs Add authority trust test + ctor update
src/Bicep.Core.UnitTests/Registry/TemplateSpecModuleRegistryTests.cs New: untrusted-cloud Template Spec restore test
src/Bicep.Core.UnitTests/Registry/OciModuleRegistryTests.cs Add untrusted-cloud OCI tests
src/Bicep.Core.UnitTests/Configuration/CloudTrustGateTests.cs New: verify trust gate precedes credential/client
src/Bicep.Core.UnitTests/Configuration/CloudConfigurationTrustPolicyTests.cs New: trust policy behavior tests
src/Bicep.Core.UnitTests/Configuration/CloudConfigurationTrustPolicyRegistrationTests.cs New: env var registration tests
src/Bicep.Core.UnitTests/Configuration/BicepConfigurationManagerTests.cs Add trusted/untrusted cloud config-chain tests
src/Bicep.Core.UnitTests/BicepTestConstants.cs Add shared test trust policy constant
src/Bicep.Core.UnitTests/Registry/Catalog/PrivateAcrModuleMetadataProviderTests.cs Update config manager construction
src/Bicep.Core.UnitTests/Mock/Registry/RegistryCatalogMocks.cs Pass trust policy into catalog
src/Bicep.Core.UnitTests/Features/FeatureProviderTests.cs Update config manager construction
src/Bicep.Core.UnitTests/Configuration/ProviderConfigurationTests.cs Update config manager construction
src/Bicep.Core.UnitTests/Configuration/ConfigurationManagerTests.cs Update built-in profile baselines + ctor updates
Review details

Suppressed comments (1)

src/Bicep.LangServer/Features/Language/Completion/AzureContainerRegistriesProvider.cs:76

  • GetArmClient builds an ArmClientOptions with the cloud-specific environment/auth scope, but the options are never passed to ArmClient. As a result, ACR discovery will run against the default public cloud even when the selected built-in profile is China/Gov/etc (or a trusted custom cloud), which breaks the intent of cloud-specific configuration.
  • Files reviewed: 35/35 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tsmallig33
Tate Smalligan (tsmallig33) marked this pull request as ready for review September 9, 2026 21:02
Comment on lines +20 to +23
"AzureGermanyCloud": {
"resourceManagerEndpoint": "https://management.sovcloud-api.de",
"activeDirectoryAuthority": "https://login.sovcloud-identity.de"
},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice this isn't yet checked in to AzureCLI. Are we OK to include it here?

@tsmallig33 Tate Smalligan (tsmallig33) Sep 10, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants